package com.zzh.tree;

public class No222_countNodes {
    public static void main(String[] args) {
        No222Solution solution = new No222Solution();
        int i = solution.countNodes(TreeNode.initTree());
        System.out.println(i);
    }
}
class No222Solution {
    private int cnt;
    public int countNodes(TreeNode root) {
        if (root==null){
            return 0;
        }
        cnt=0;
        count(root);
        return cnt;
    }
    private void count(TreeNode root){
        if (root==null){
            return;
        }
        cnt++;
        count(root.left);
        count(root.right);
    }
}